package com.unisyou;

import com.unisyou.entity.EmployeeEntity;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

public class Demo6 {
    public static void main(String[] args) {
        List<EmployeeEntity> list = new ArrayList<>();

        EmployeeEntity employeeEntity = new EmployeeEntity();
        employeeEntity.setEmployeeName("陈依依");
        employeeEntity.setReadLength(19);
        list.add(employeeEntity);
        employeeEntity = new EmployeeEntity();
        employeeEntity.setEmployeeName("王五");
        employeeEntity.setReadLength(81);
        list.add(employeeEntity);
        employeeEntity = new EmployeeEntity();
        employeeEntity.setEmployeeName("赵四");
        employeeEntity.setReadLength(0);
        list.add(employeeEntity);
        System.out.println("未排序:"+list);
        list = list.stream().sorted(Comparator.comparing(EmployeeEntity::getReadLength, Comparator.reverseOrder())).collect(Collectors.toList());

        System.out.println("已排序:"+list);


    }
}
